package org.gpslw.autoconfig;

import org.geolatte.geom.json.Setting;
import org.geolatte.geom.json.Settings;
import org.geotools.jdbc.JDBCDataStore;
import org.gpslw.util.DataStoreUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Configuration
public class OpenGisDataStoreConfig{
    @Bean
    public Settings settings() {
        Settings settings = new Settings();
        settings.override(Setting.SERIALIZE_FEATURE_BBOX, true);
        settings.override(Setting.SERIALIZE_FEATURE_COLLECTION_BBOX, true);
        settings.override(Setting.SERIALIZE_CRS_AS_URN, true);
        settings.override(Setting.SUPPRESS_CRS_SERIALIZATION, false);
        settings.override(Setting.IGNORE_CRS, false);
        return settings;
    }

    @Bean
    public JDBCDataStore dataStoreUtils(DataSource dataSource) {
        return DataStoreUtils.getDataStore(dataSource);
    }

}
